package com.cskaoyan.javase.homework.day11.extend;

/**
 * @description: 扩展一
 * @author: wuguidong@cskaoyan.onaliyun.com
 **/

public class Demo {
    public static void main(String[] args) {
        new Student("张三");
    }
}

class Student {
    int age;
    String name;
    static int var;

    {
        var = 200;
    }

    public Student() {
    }

    public Student(int age) {
        this.age = age;
    }

    public Student(String name) {
        //语法上不能用自身的成员变量作为this调用构造器的参数,只能用静态成员变量
        //1.如果语法允许,它永远是0没有意义,2.父类构造器还没有执行,该成员变量还未能赋值,无法作为参数,它的赋值还不准确
        //Cannot reference 'Student.var' before supertype constructor has been called
        this(var);
        this.name = name;
    }
}